package work20241203_chap6oop.p_demo13;

/**
 * @author zdl
 * @date 2024/12/5
 */
class Shape {
    public void area() {
    }

    ;

    public void girth() {
    }

    ;
}

class Circle extends Shape {
    private double r;

    public Circle() {
    }

    public Circle(double r) {
        this.r = r;
    }

    @Override
    public void area() {
        System.out.println("圆形面积:" + (3.14 * r * r));
    }

    @Override
    public void girth() {
        System.out.println("圆形周长:" + (2 * 3.14 * r));
    }

    /**
     * 获取
     * @return r
     */
    public double getR() {
        return r;
    }

    /**
     * 设置
     * @param r
     */
    public void setR(double r) {
        this.r = r;
    }

    public String toString() {
        return "Circle{r = " + r + "}";
    }
}
class T{
    public void test(Shape shape){
        if (shape instanceof Circle){
            shape.area();
            shape.girth();
        }

    }
}
public class Demo {
    public static void main(String[] args) {
        Circle circle = new Circle(3);
        T t = new T();
        t.test(circle);
    }

}
